next up previous
Next: 4.6 Xt Argument Lists Up: 4 The Effects of Previous: 4.4 Pitfalls of 32-bit

4.5 Careful with X Images

Another area of Xlib programming that is prone to 64-bit portability problems is use of Xlib's image routines that manipulate XImage* data structures: XCreateImage, XGetImage, XPutImage, XGetSubImage, etc. If the routines used to manipulate pixels in XImage* objects are limited to the standard interfaces like XGetPixel and XPutPixel, your code is very likely to be portable.

But with sufficient understanding of the format of image data, application code can be rewritten without XGetPixel and XPutPixel to substantially speed up pixel operations on XImage* objects. The XGetPixel and XPutPixel routines have fairly high overhead due to their generality and tend to be called repeatedly so this is a good area for optimization. Such optimizations are ripe for 64-bit portability bugs because the code involved is often dependent on the size of basic data types. Potentially, with more tuning, you can actually improve the performance of your image operations by using 64-bit operations to move data faster.

A good idea when optimizing image operations is to code an unoptimized, safe version of the operation using XGetPixel and XPutPixel. This makes it easy to fall back to the safe version of the image operation if the assumptions for the optimization are incorrect.



next up previous
Next: 4.6 Xt Argument Lists Up: 4 The Effects of Previous: 4.4 Pitfalls of 32-bit



Mark Kilgard
Sat Dec 30 11:52:07 PST 1995